import axios from '../http';
import { Base, ResAId } from '../interface/base';

interface GroupType extends Base {
	u_id: number;
	name: string;
}

interface GruopDetailType extends GroupType {
	cards: Array<{
		card_id: number;
		u_id: number;
		name: string;
	}>;
}

// 获取牌组详情
export const getGroupInfo = async (groupId: number): Promise<GruopDetailType> => axios.get(`mjconf/group/${groupId}`);

// 牌组列表
export const getDeckList: GetListApi<{}, GroupType> = async (params) => axios.get('mjconf/group', { params });

// 添加牌组
export const addDeck = (data: { name: string }): ResAId => axios.post('mjconf/group', data);

// 修改牌组信息
export const changeDeck = (groupId: number, name: string) => axios.put(`mjconf/group/${groupId}`, { name });

// 删除牌组
export const delDeck = (groupId: number) => axios.delete(`mjconf/group/${groupId}`);
